package com.OnTimeTeam.OnTime;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.TextView;

public class VibrationList extends ArrayAdapter<Boolean> {

	private ArrayList<Boolean> items; //all alarms details

	///////////////
	//CTOR - init' the array of AlarmFeatures and ApplicationContext object
	public VibrationList(Context context, int textViewResourceId, ArrayList<Boolean> items) {
		super(context, textViewResourceId, items);
		this.items = items;
	}

	////////////////////
	//This method sets the view of ONE item in the list (it gets it's index - it's the same index as the AlarmFeatures ArrayList)
	public View getView(final int index, View convertView, ViewGroup parent) {
	
		View view = convertView;
		LayoutInflater inflater = null;
		
		if (view == null) {
			inflater = (LayoutInflater)this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			view = inflater.inflate(R.layout.single_choice_item, null);//set the view
		}
		
		TextView choice = (TextView)view.findViewById(R.id.choiceItem);
		CheckBox check = (CheckBox)view.findViewById(R.id.check); 
		check.setFocusable(false);
		check.setClickable(false);
		
		check.setChecked(false);
		
		switch(index){
		
			case 0:
				choice.setText(getContext().getResources().getString(R.string.none));
				
				if(items.get(index))
					check.setChecked(true);
				
				break;
			case 1:
				
				choice.setText(getContext().getResources().getString(R.string.vibStandard1));
				if(items.get(index))
					check.setChecked(true);
				break;
			case 2:
				choice.setText(getContext().getResources().getString(R.string.vibStandard2));
				
				if(items.get(index))
					check.setChecked(true);
				
				break;		
			case 3:
				choice.setText(getContext().getResources().getString(R.string.vibFast));

				if(items.get(index))
					check.setChecked(true);
				
				break;		
			case 4:
				choice.setText(getContext().getResources().getString(R.string.vibIntensive));
				
				if(items.get(index))
					check.setChecked(true);
				
				break;	
			case 5:
				choice.setText(getContext().getResources().getString(R.string.vib3Busrts));
				
				if(items.get(index))
					check.setChecked(true);
				
				break;
			case 6:
				choice.setText(getContext().getResources().getString(R.string.vibMorse));
				
				if(items.get(index))
					check.setChecked(true);
				
				break;
		}//end cases
		
		//return the view of the item
		return view;
	
	}//end of method 'getView'
	
}//EOF

